#ifndef DEF_H__
#define DEF_H__

#include <stdio.h>

#define TIME_STAMP_LENGTH	100

#define TIME_STAMPS_CLOCK		0
#define TIME_STAMPS_INTERVAL	1

const int QUERY_ID_NULL			= -1;
const int QUERY_ID_LOGLEVEL		= 1;
const int QUERY_ID_LINETYPE		= 2;
const int QUERY_ID_KEYID		= 3;
const int QUERY_ID_CONSOLEID	= 4;

//QUERY_ID_LOGLEVEL
	const int LOG_LEVEL_CLOSE	= 0;
	const int LOG_LEVEL_LOW		= 1;
	const int LOG_LEVEL_NORMAL	= 5;
	const int LOG_LEVEL_HIGH	= 10;

//QUERY_ID_LINETYPE
	const int LOG_TYPE_NOTIFICATION = 0;
	const int LOG_TYPE_WARNING		= 1;
	const int LOG_TYPE_EXCEPTION	= 2;

//QUERY_ID_KEYID
	const int	KEYID_NULL		= -1;

//QUERY_ID_CONSOLEID
	const int	CONSOLEID_NULL	= 0;

	class CTimeStamp
{
public:
	virtual LPCSTR getTimeStamp() =0;	
protected:
	char m_sBuffer[TIME_STAMP_LENGTH];
};

class CClockTimeStamp : public CTimeStamp
{
public:
	LPCSTR getTimeStamp()
	{
		memset(m_sBuffer,0,TIME_STAMP_LENGTH);

		SYSTEMTIME st;
		GetLocalTime(&st);
		
		sprintf_s(m_sBuffer,TIME_STAMP_LENGTH,"%02d-%02d-%04d %02d:%02d:%02d:%03d ",
				st.wDay,
				st.wMonth,
				st.wYear,
				st.wHour,
				st.wMinute,
				st.wSecond,
				st.wMilliseconds);

		return m_sBuffer;
	}

};

class CInterValTimeStamp : public CTimeStamp
{
public:
	LPCSTR getTimeStamp()
	{
		memset(m_sBuffer,0,TIME_STAMP_LENGTH);

		DWORD time = GetTickCount();
		sprintf_s(m_sBuffer,TIME_STAMP_LENGTH,"%d ",time);
		return m_sBuffer;

	}

};

class CTimeFactory
{
	public:
		static CTimeStamp* factory(int id)
		{
			switch (id)
				{
				case TIME_STAMPS_CLOCK:		return dynamic_cast<CTimeStamp*>(new CClockTimeStamp);
				case TIME_STAMPS_INTERVAL:	return dynamic_cast<CTimeStamp*>(new CInterValTimeStamp);
				}
			 
			return NULL;
		}


};

#endif